import Vue from "vue";
import Router from "vue-router";
import Layout from "@/layout/index.vue";
import {
  getToken,
  setToken,
  removeToken,
  getStoreId,
  setStoreId,
  removeStoreId,
  setUserInfo,
  getUserInfo,
  removeUserInfo
} from "@/utils/cookies";
import store from "@/store";

Vue.use(Router);

const router = new Router({
  scrollBehavior: (to, from, savedPosition) => {
    if (savedPosition) {
      return savedPosition;
    }
    return { x: 0, y: 0 };
  },
  base: process.env.BASE_URL,
  routes: [
    {
      path: "/admin/login",
      component: () => import("@/views/login/index.vue"),
      meta: { title: "mbti人格测试-管理端登录", hidden: true, notNeedAuth: true }
    },
    {
      path: "/user/login",
      component: () => import("@/views/login/UserIndex.vue"),
      meta: { title: "mbti人格测试-用户端登录", hidden: true, notNeedAuth: true }
    },
    {
      path: "/404",
      component: () => import("@/views/404.vue"),
      meta: { title: "mbti人格测试-管理端", hidden: true, notNeedAuth: true }
    },
    {
      path: "/",
      component: Layout,
      redirect: "/dashboard",
      children: [
        {
          path: "role",
          component: () =>  import("@/views/role/index.vue"),
          name: "role",
          meta: {
            title: "人格展示",
            icon: "dashboard",
            affix: true
          }
        },
		    {
          path: "statistics",
          component: () => import("@/views/statistics/index.vue"),
          meta: {
            title: "数据统计",
            icon: "icon-statistics"
          }
        },
        {
          path: "question",
          component: () => import("@/views/question/index.vue"),
          meta: {
            title: "题目管理",
            icon: "icon-combo"
          }
        },
       
        {
          path: "student",
          component: () => import("@/views/student/index.vue"),
          meta: {
            title: "学生管理",
            icon: "icon-order"
          }
        },
        {
          path: "/student/add",
          component: () => import("@/views/student/addStudent.vue"),
          meta: {
            title: "添加学生",
            hidden: true
          }
        },
        {
          path: "class",
          component: () => import("@/views/class/index.vue"),
          meta: {
            title: "班级管理",
            icon: "icon-order"
          }
        },
        {
          path: "/class/add",
          component: () => import("@/views/class/addClass.vue"),
          meta: {
            title: "添加班级",
            hidden: true
          }
        },
        {
          path: "major",
          component: () => import("@/views/major/index.vue"),
          meta: {
            title: "专业管理",
            icon: "icon-dish"
          }
        },
        {
          path: "/major/add",
          component: () => import("@/views/major/addMajor.vue"),
          meta: {
            title: "添加专业",
            hidden: true
          }
        },
        
        {
          path: "college",
          component: () => import("@/views/college/index.vue"),
          meta: {
            title: "学院管理",
            icon: "icon-category"
          }
        },
        {
          path: "/college/add",
          component: () => import("@/views/college/addCollege.vue"),
          meta: {
            title: "添加学院",
            hidden: true
          }
        },
        {
          path: "admin",
          component: () => import("@/views/employee/index.vue"),
          meta: {
            title: "员工管理",
            icon: "icon-employee"
          }
        },
        
        {
          path: "/admin/add",
          component: () => import("@/views/employee/addEmployee.vue"),
          meta: {
            title: "添加/修改员工",
            hidden: true
          }
        },
        
        {
          path: "/question/add",
          component: () => import("@/views/question/addQuestion.vue"),
          meta: {
            title: "添加题目",
            hidden: true
          }
        }
      ]
    },
    {
      path: "/user",
      component: () => import("@/layout/StudentLayout.vue"),
      redirect: "/class",
      children: [
        {
          path: "role",
          component: () =>  import("@/views/role/index.vue"),
          name: "role",
          meta: {
            title: "人格展示",
            icon: "dashboard",
            affix: true
          }
        },

		    {
          path: "detail",
          component: () => import("@/views/detail/index.vue"),
          meta: {
            title: "学生人格详情",
            icon: "icon-statistics"
          }
        },
        {
          path: "test",
          component: () => import("@/views/test/index.vue"),
          meta: {
            title: "题目测试",
            icon: "icon-combo"
          }
        },
       
      ]
    },
    {
      path: "*",
      redirect: "/404",
      meta: { hidden: true }
    }
  ]
});

export default router;
